#coding:utf-8
from bs4 import BeautifulSoup
Path='./programs/classreminder/'
class XD_remind():
    def __init__(self):
        pass
    def search_data(self):
        pass
    def deal_data(self):
        classlisto=[]
        classlistf=[]
        weekdict={"一":1,"二":2,"三":3,"四":4,"五":5,"六":6,"七":7,}
        with open(Path+"schedules/class.txt",'r',encoding='utf-8') as f:
                str=f.read()
                soup=BeautifulSoup(str,'lxml')
                div_list=soup.find_all('tr')
        for i in div_list:
                list=i.find_all('td')
                dict={'班级':list[4].text,'周数':list[16].text,'时间':list[18].text,'教师':list[13].text,'地点':list[19].text}
                if dict not in classlisto:
                    classlisto.append(dict)
        classlisto.pop(0)
        for i in classlisto:
            zslist=[]
            l=i['周数'].split(',')
            for j in l:
                start=int(j.split('-')[0])
                end=int(j.split('-')[1])
                for k in range(start,end+1):
                    zslist.append(k)
            dict={'班级':i['班级'].split(']')[1],'周数':zslist,'星期':weekdict[i['时间'][0]],'时间':i['时间'][2:][:-2],'教师':i['教师'].split(']')[1],'地点':i['地点']}
            classlistf.append(dict)
        return classlistf


